<template>
	<view class="logisticsInformation">
		<view class="content" v-for="(item,index) in info" :key="index">
          <view class="line">
			  <text>运单号：{{item.express_no}}</text>
			  <text class="copy" @click="getcopy(index)">复制</text>
		  </view>
		   <view class="line">
			   <text>快递公司：{{item.express_company}}</text>
		   </view>
		</view>
		<view class="ts">温馨提示：复制运单号查询快递</view>
		<view class="bottom" @click="jump('kuaidi100')">查询快递</view>
	</view>
</template>

<script>
	import serve from '../../static/request.js';
	import storage from '../../static/appkey.js';
	import common from '../../static/jump.js';
	// import clipboard from '../../static/clipboard.js';
	export default {
		data() {
			return {
				id: 0,
				info: {},
			}
		},
		methods: {
			getcopy(key){
				let express_no = this.info[key].express_no;
				uni.setClipboardData({
					data: express_no,
					success: function (){
						uni.showToast({
							title: '复制成功',
							icon: 'none',
						});
					},
					fail:function(){
						uni.showToast({
							title: '对不起，您微信当前版本不支持复制功能',
							icon: 'none',
						});
					}
				});
				uni.getClipboardData({
				    success: function (res) {
				        console.log(res.data);
				    }
				});
			},
			getInfo() {
				var self = this;
				serve
					.request({
						url: '/member/order/delivery',
						data: {
							appkey: uni.getStorageSync('appkey'),
							'access-token': uni.getStorageSync('access-token'),
							id: self.id
						}
					})
					.then(res => {
						if(res.code != 200) {
							uni.showToast({
								title:res.message,
								icon: 'none',
								success() {
									setTimeout(function () {
										self.jump('order_view', self.id)
									}, 2000) 
								}
							});
						}
						self.info = res.data;
					});
			},
			jump(jump_type, jump_link){
				common.jump(jump_type, jump_link);
			}
		},
		onLoad(options) {
			this.id=options.id || 0;
			if(this.id == 0) {
				uni.showToast({
					title: "错误的访问方式",
					icon: 'none',
					success() {
						setTimeout(function () {
							self.jump('my_order_list')
						}, 2000) 
					}
				});
			}
			this.getInfo();
		},
		onPullDownRefresh() {
			console.log('refresh');
			this.getInfo();
		}
	}
</script>


<style scoped lang="scss">
	.logisticsInformation {
		min-height: 100vh;
		background: #FFFFFF;

		.ts {
			padding: 50rpx 30rpx;
			font-size: 32rpx;
			color: #999999;
		}

		.content {
			box-sizing: border-box;
			width: 100%;
			padding: 40rpx 30rpx;
			background: #FFFFFF;
            border-bottom: 16rpx #F7F7FA solid;
			.line {
				font-size: 32rpx;
                color: #666666;
				.copy {
					color: #EB5938;
					font-size: 24rpx;
					margin-left: 40rpx;
					padding: 4rpx 27rpx;
					background:rgba(255,255,255,1);
					border:1rpx solid #EB5938;
					border-radius:20rpx;
				}
			}

			.line:last-child {
				padding-top: 30rpx;
			}
		}

		.bottom {
			width: 100%;
			height: 100rpx;
			line-height: 100rpx;
			text-align: center;
			font-size: 32rpx;
			color: rgba(255, 255, 255, 1);
			background: #FFBC00;
			bottom: 0rpx;
			position: fixed;
		}
	}
</style>
